package cn.datawin.cotask.util;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import cn.datawin.cotask.bo.CoTask;


public class PaserUtil {
	
	public static List<CoTask> dboToTask(List<Map<String, Object>> list){
		List<CoTask> tasklist = new ArrayList<CoTask>();
		if (list!=null &&list.size() >0) {
			for (int i = 0; i < list.size(); i++) {
				Map<String, Object> map = list.get(i);
				CoTask task = new CoTask();
				task.setId((String)map.get("_id"));
				task.setWorkbeach((String)map.get("workbeach"));
				task.setType((String)map.get("type"));
				task.setSig((String)map.get("sig"));
				
				task.setState((String)map.get("state"));
				task.setMethod((String)map.get("method"));
				task.setUrl((String)map.get("url"));
				task.setCharset((String)map.get("charset"));
				task.setClientid((String)map.get("clientid"));
				
				task.setHeader((Map<String, String>)map.get("header"));
				task.setCookie((Map<String, String>)map.get("cookie"));
				task.setRules((List<Map<String, Object>>)map.get("rules"));
				task.setData((Map<String, String>)map.get("data") );
				task.setExtedata((Map<String, String>)map.get("extedata"));
				tasklist.add(task);
			}
		}
		return tasklist;
	}
	
}
